{% set pypi_name = 'oslo.rootwrap' %}
{% set upstream_version = upstream_version('6.2.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Filtering shell commands to run as root from OpenStack services
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  iproute2
%else
BuildRequires:  iproute
%endif

%description
oslo.rootwrap allows fine-grained filtering of shell commands to run as root
from OpenStack services.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Filtering shell commands to run as root from OpenStack services
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 6.0.1
%endif

%description -n {{ py2name(py_versions='py3') }}
oslo.rootwrap allows fine-grained filtering of shell commands to run as root
from OpenStack services.

This package contains the Python 3.x module.

%package -n {{ py2name() }}-doc
Summary:        Documentation for OpenStack {{ pypi_name }}
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name() }}-doc
Documentation for the OpenStack {{ pypi_name }} library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
export PYTHONPATH=.
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/oslo_rootwrap
%{python3_sitelib}/*.egg-info
%{_bindir}/oslo-rootwrap
%{_bindir}/oslo-rootwrap-daemon

%files -n {{ py2name() }}-doc
%license LICENSE
%doc doc/build/html

%changelog
